import request from "./axios";

interface IResponseType<P = {}> {
  code?: number;
  status?: number;
  message: string;
  data: P;
}

// 获取首页内容
const getHomeDetail = () => {
  return request<IResponseType>({
    url: `/home/find`,
    method: "GET",
  });
};

// 获取文章列表
const getArtList = (data?: any) => {
  return request<IResponseType>({
    url: `/article/find?page=${data.page}&pageSize=${data.pageSize}&title=${data?.title}&type=${data?.type}`,
    method: "GET",
  });
};

// 获取文章详情
const getArtDetail = (data?: any) => {
  // http://43.138.31.67:7001/api/article/detail/0000000008?0=0000000008
  return request<IResponseType>({
    url: `/article/detail/${data.id}`,
    method: "GET",
  });
};
// 提交留言
const passMessage = (data?: any) => {
  return request<IResponseType>({
    url: `/mail/create`,
    method: "POST",
    data,
  });
};
export { getHomeDetail, getArtList, getArtDetail, passMessage };
